﻿using Fast.ExceptionHandling;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace Fast.Validation
{
    /// <summary>
    /// 模型验证异常
    /// </summary>
    [SkipScan]
    public class FastValidationException : FastException,
        IHasValidationErrors
    {
        /// <summary>
        /// 模型验证异常消息列表
        /// </summary>
        public IList<ValidationResult> ValidationErrors { get; }

        /// <summary>
        /// 构造函数
        /// </summary>
        public FastValidationException()
        {
            ValidationErrors = new List<ValidationResult>();
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="message"></param>
        public FastValidationException(string message)
            : base(message)
        {
            ValidationErrors = new List<ValidationResult>();
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="validationErrors"></param>
        public FastValidationException(IList<ValidationResult> validationErrors)
        {
            ValidationErrors = validationErrors;
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="message"></param>
        /// <param name="validationErrors"></param>
        public FastValidationException(string message, IList<ValidationResult> validationErrors)
            : base(message)
        {
            ValidationErrors = validationErrors;
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="message"></param>
        /// <param name="innerException"></param>
        public FastValidationException(string message, Exception innerException)
            : base(message, innerException)
        {
            ValidationErrors = new List<ValidationResult>();
        }


    }
}
